package ca.ericslandry.shared.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Embedded;
import javax.persistence.Id;
import javax.persistence.Transient;

public class Issue implements Serializable {
	private static final long serialVersionUID = 1765191763263990140L;
	@Id
	Long id;
	String title;
	String description;
	@Embedded
	User creator;
	String geohash;
	Date creationDate;
	@Transient
	int viewCount;

	public Issue() {
	}

	public Issue(String title, String description, User creator, String geohash, Date creationDate) {
		this.title = title;
		this.description = description;
		this.creator = creator;
		this.geohash = geohash;
		if (creationDate == null) {
			creationDate = new Date();
		}
		this.creationDate = creationDate;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getGeohash() {
		return geohash;
	}

	public void setGeohash(String geohash) {
		this.geohash = geohash;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	@Override
	public String toString() {
		return getClass().getName() + id;
	}

	public int getViewCount() {
		return viewCount;
	}

	public void setViewCount(int viewCount) {
		this.viewCount = viewCount;
	}

	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}
}
